package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.ThingBean;
import com.project.service.IThingService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * @author RJ
 * @date 2022/9/16 10:05
 */
@RestController
@RequestMapping("thing")
public class ThingController {
    @Resource
    private IThingService thingService;

    @RequestMapping("add")
    public String addThing(ThingBean thingBean) {
        thingService.addThing(thingBean);
        return "ok";
    }

    @RequestMapping("get")
    public ThingBean getThingInfo(Integer thingId) {
        ThingBean thingBean = thingService.getThingInfo(thingId);
        return thingBean;
    }

    @RequestMapping("update")
    public String updThing(Integer thingId, String thingStage, String thingScheme) {
        thingService.updThing(thingId, thingStage, thingScheme);
        return "ok";
    }

    @RequestMapping("info")
    public IPage<ThingBean> cutThingByItem(Integer pageNo, Integer pageSize, String thingName, String thingStage,
                                           String areaName, LocalDate startDate, LocalDate endDate) {
        IPage<ThingBean> page = thingService.cutThingByItem(pageNo, pageSize, thingName, thingStage, areaName, startDate, endDate);
        return page;
    }

    @RequestMapping("stage")
    public String updStage(Integer thingId, String thingStage) {
        thingService.updStage(thingId, thingStage);
        return "ok";
    }
}
